package com.techzhi.addres_score.util;

import org.springframework.boot.SpringBootVersion;

public class VersionCompatibilityUtils {

    private static final String SPRING_BOOT_VERSION = SpringBootVersion.getVersion();

    public static boolean isSpringBoot3() {
        return SPRING_BOOT_VERSION != null && SPRING_BOOT_VERSION.startsWith("3");
    }

    public static boolean isJava17OrHigher() {
        String javaVersion = System.getProperty("java.version");
        return javaVersion != null &&
                (javaVersion.startsWith("17") ||
                        javaVersion.startsWith("18") ||
                        javaVersion.startsWith("19") ||
                        javaVersion.startsWith("20") ||
                        javaVersion.startsWith("21"));
    }

    public static void checkCompatibility() {
        if (isSpringBoot3() && !isJava17OrHigher()) {
            throw new IllegalStateException("Spring Boot 3 requires Java 17 or higher");
        }
    }
}
